package OPeration;

import book.Book;
import book.BookList;

import java.util.Scanner;

public class FindOPeration
        implements IOPeration {//查找图书
    @Override
    public void work(BookList bookList) {
        System.out.println("Find~~");
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入你要查找的图书:");
        String name = scanner.nextLine();
        int currentSize = bookList.getUsedSize();
        for (int i = 0; i < currentSize; i++) {
            Book book = bookList.getBook(i);
            if(name.equals(book.getName())) {
                System.out.println("找到了...");
                System.out.println(book);
                return;
            }
        }
        System.out.println("没有你要找的书...");
    }
}
